\documentclass[12pt]{article}
\usepackage[paper=letterpaper,nohead,margin=1in]{geometry}
\usepackage{url}
 
\title{A {\tt snppy} extension for facilitating SNP imputation}
\begin{document}
\maketitle
In this document we outline the requirements for using snppy
to facilitate GWAS imputation analysis using the
MaCH~\cite{MACH2009,MACH2010} software.
\section{Notation}
Let $G$ denote the set of all rsids. Let $G_k$ be the set of
rsids in chromosome $k\in\{1,..,22,{\mathit X,Y,XY,MT}\}$. Note that
these sets are mutually exclusive and that $G=\cup_k G_k$. 
Finally, tet $G_0$ denote a set of SNPs 
to be excluded from the imputation analyses (this file will contain
20-30\% of the SNPs in $G$ [it is a large set]).
\section{MACH requirements}
We assume that the GWAS data has been loaded into the {\tt snppy} database.
To facilitate the imputation process using MACH, for each chromosome
of interest we have to produce a pair of files (say {\tt chrk.ped}
and {\tt chrk.dat})
\begin{itemize}
\item {\tt chrk.ped} is a modified ped file restricted to 
      $G_k \cap \bar{G}_0$ (i.e., all snps
      on chromosome $k$ excluding the snps in $G_0$). 
      This ped file is modified in the following sense
      \begin{itemize}
      \item It does not have the outcome column
      \item The sex column should be coded as 'M' or 'F'
      \end{itemize}
\item {\tt chrk.dat} is a modified version of the MAP 
      file that consist of only two
      columns: The first column will be the string 'M' (for all rows)
      The second columns will be the rsid.
      Note that the order of the rsids in this file have to follow
      that of the snps in {\tt chrk.ped} 
\end{itemize}
The files are then processed as follows:
\begin{tiny}
\begin{verbatim}
$ mach1 -d chr1.dat -p chr1.ped -s hm3_r2_b36_fwd.CEU.chr1.snps -h hm3_r2_b36_fwd.CEU.chr1.hap --options 
$ mach1 -d chr2.dat -p chr2.ped -s hm3_r2_b36_fwd.CEU.chr2.snps -h hm3_r2_b36_fwd.CEU.chr2.hap --options
...
...
$ mach1 -d chr22.dat -p chr22.ped -s hm3_r2_b36_fwd.CEU.chr22.snps -h hm3_r2_b36_fwd.CEU.chr22.hap --options
\end{verbatim}
\end{tiny}
The files indicated by the {\tt -s} and {\tt -h} flags are downloaded from the HapMap site (these are
reference files).
Additional details are found here \url{http://www.sph.umich.edu/csg/abecasis/MACH/tour/}.
Notes:
\begin{itemize}
\item The set $G_0$
      is large. So somehow, snppy has to read this set from a file
      (rather than having us handtype a long list of rsids in the SQL
      query)
\item 
Suggested usage: In this example, we want to process chromosomes 1 through 22.
The chromosomes to be excluded are in the file {\tt  exclude-snp.txt}.
We want for format them for use with MaCH (hence the {\tt --method} flag).

\begin{footnotesize}
\begin{verbatim}
$ python snppy2impute.py --method mach --chr 1-22 --anno forward\
  --exclude exclude-snp.txt --refdat hapmap3-r2-b36-CEU-reflist.csv
\end{verbatim}
\end{footnotesize}
The locations of the reference data are provided in a file called {\tt hapmap3-r2-b36-CEU-reflist.csv }.
that is formatted as follows:
\begin{footnotesize}
\begin{verbatim}
1,refdat/snps/hm3_r2_b36_fwd.CEU.chr1.snps,refdat/haplo/hm3_r2_b36_fwd.CEU.chr1.hap
2,refdat/snps/hm3_r2_b36_fwd.CEU.chr2.snps,refdat/haplo/hm3_r2_b36_fwd.CEU.chr2.hap
...
...
22,refdat/snps/hm3_r2_b36_fwd.CEU.chr22.snps,refdat/haplo/hm3_r2_b36_fwd.CEU.chr22.hap
\end{verbatim}
\end{footnotesize}
\end{itemize}

\section{Text for the paper (added to the Discussion Section)}
SNP imputation~\cite{Halperin2009} methods are commonly employed
to conduct inference on the basis of SNPs not typed on the GWAS platform. 
Two commonly used SNP imputation algorithms are MaCH~\cite{MACH2009,MACH2010}
and IMPUTE~\cite{IMPUTE2007,IMPUTE2009}. As the conduct of imputation 
across the entire genome is computationally prohibitive, the task is 
commonly split up across the chromosomes or other sub-regions of the genome.
Accordingly, the study data has to be split into a set of individual files 
each restricted to the set of SNPs in the corresponding
chromosome.
Our proposed database framework can be readily extended to facilitate the
requisite pre-processing to produce these files. Given that {\tt snppy} 
is a Python
framework, it can be further extended to directly 
call the imputation program after
the files have been generated. Moreover, as the process of conducting
imputation analyses across mutually exclusive regions presents
an embarrassingly parallel problem, one can readily employ the
Python threading facilities to fully utilize the computational
power of high memory multicore servers.
\bibliographystyle{plain}
\bibliography{snppy-impute-plugin}
\end{document}


